import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

/// A widget that displays a horizontal row of option items.
class OptionCard extends StatelessWidget {
  const OptionCard({super.key});

  @override
  Widget build(BuildContext context) {
    final localizations = AppLocalizations.of(context)!;
    return Padding(
      padding: const EdgeInsets.all(15),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceAround,
        children: List.generate(4, (index) {
          return _OptionItem(
            iconData:
                [
                  Icons.edit,
                  Icons.refresh,
                  Icons.share,
                  Icons.swap_horiz,
                ][index],
            localizedText:
                [
                  localizations.editOption,
                  localizations.changeOption,
                  localizations.shareOption,
                  localizations.switchOption,
                ][index],
          );
        }),
      ),
    );
  }
}

/// A widget that displays a single option item with an icon and text.
class _OptionItem extends StatelessWidget {
  const _OptionItem({required this.iconData, required this.localizedText});

  final IconData iconData;
  final String localizedText;

  @override
  Widget build(BuildContext context) {
    final theme = Theme.of(context);
    return Column(
      children: [
        Icon(iconData),
        const SizedBox(height: 5),
        Text(
          localizedText,
          textAlign: TextAlign.center,
          style: TextStyle(
            fontSize: 12,
            color: theme.textTheme.bodyMedium!.color,
          ),
        ),
      ],
    );
  }
}
